/**
 * 种植架构建工具
 */
import * as THREE from 'three'

export interface Position {
    x: number
    y: number
    z: number
}

export interface PotConfig {
    width: number
    height: number
    depth: number
    color: number
    position?: Position
}

export class Pot {
    _geometry: any = null
    _material: any = null
    _cube: any = null

    constructor(config: PotConfig) {
        // 创建花盆
        // 几何对象
        this._geometry = new THREE.BoxGeometry( config.width,config.height,config.depth )
        // 材质
        this._material = new THREE.MeshBasicMaterial( { color: config.color } )
        // Mesh网格包含一个几何体以及作用在此几何体上的材质
        this._cube = new THREE.Mesh( this._geometry, this._material )
        this.setPosition(config.position)
    }

    /**
     * 设置花盆位置
     */
    setPosition(position: Position) {
        this._cube.position.x = position.x
        this._cube.position.y = position.y
        this._cube.position.z = position.z
    }
}